<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<style type="text/css">
    .pageContent label {
        width: 100px;
    }
    .pageFormContent p {
        width: 430px;
    }
</style>
<div class="pageContent" style="padding-top: 1px;">
    <form method="post"  class="pageForm required-validate" id="uploadForm" enctype="multipart/form-data">
        <div class="pageFormContent" layoutH="56">
            <p style="width: 100%;">
                <label>保安员考试成绩：</label> <input name="examScore" type="file" size="30" style="width:300px;" class="required" accept=".xls"/>
            </p>
            <p style="width: 100%;"></p>
            <p style="width: 80%; float: right;">
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注：上传文件格式只能为.xls格式，第一行填写标题，与表格顺序一致，表格内容全部为文本格式。
            </p>
        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button onclick="apiEditCallback()">保存</button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">取消</button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>
<script type="text/javascript">
    function apiEditCallback(resp) {
        var formData = new FormData($( "#uploadForm" )[0]);
        $.ajax({
            type : "POST",
            url : "<c:url value='/security/saveImportExamScore'/>",
            data : formData,
            processData: false,  // 告诉jQuery不要去处理发送的数据
            contentType: false,  // 告诉jQuery不要去设置Content-Type请求头
            async : false,
            cache: false,
            success : function(resp){
                if(resp&&resp.succ){
                    alertMsg.info("操作成功！");
//                    $.pdialog.closeCurrent();
//                    navTab.reloadFlag('page_exam_questions')
                }else {
                    alertMsg.info(resp.msg + "!");
                }
            },
            error : function(XMLHttpRequest, textStatus,errorThrown) {
                alertMsg.info(errorThrown);
            }
        });
    }
</script>
